package com.xiangge.zuoye.Demo3;


import com.xiangge.zuoye.Demo2.Rectangle;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/3/17 17:50
 * @description
 */
public class RectangleTest2 {
    public static void main(String[] args) {
        Rectangle[] arr = new Rectangle[5];
        for (int i = 0; i < arr.length; i++) {
            int chang = (int) ((Math.random() * (10 + 1 - 1)) + 1);
            int kuan = (int) ((Math.random() * (10 + 1 - 1)) + 1);
            Rectangle temp = new Rectangle(chang, kuan);
            arr[i] = temp;
        }
        for (Rectangle rectangle : arr) {
            rectangle.getInfo();
        }
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if (arr[i].getArea()<arr[j].getArea()){
                    Rectangle temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println("========================");
        for (Rectangle rectangle : arr) {
            rectangle.getInfo();
        }
    }
}
